package cn.bdqn.fifthmedic.systrm.controller;

import cn.bdqn.fifthmedic.model.EData;
import cn.bdqn.fifthmedic.model.PageBean;
import cn.bdqn.fifthmedic.model.R;
import cn.bdqn.fifthmedic.systrm.model.User;
import cn.bdqn.fifthmedic.systrm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Yuan
 * @create 2020-02-14 10:42
 */
@Controller
@RequestMapping("fm/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("page")
    public String userpage(){
        return "system/user";
    }
//显示
    @GetMapping
    @ResponseBody
    public EData list(PageBean pageBean, String name){

        return userService.list(pageBean, name);
    }
//保存
    @PostMapping
    @ResponseBody
    public R save(User user){
        return userService.save(user);
    }
//删除
    @PostMapping("delete")
    @ResponseBody
    public R del(Integer id){
        return userService.del(id);
    }

    @PostMapping("saveRoleSet")
    @ResponseBody
    public R saveRoleSet(String roleIds,String roleNames,Integer userId){
        return userService.saveRoleSet(roleIds,roleNames,userId);
    }

}
